/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.csc531;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

import com.csc531.lists.TaskListByCourses;
import com.csc531.lists.TaskListByUpcoming;
import com.csc531.lists.NotesList;

/**
 * @author Javier Figueroa
 *
 * Main of the project. 
 */
public class Manager extends TabActivity 
{
	//list type
	public static final int CLASSES_FATLIST = 0;
	public static final int CLASSES_THINLIST = 1;
	public static final int MAP_VIEW = 2;
	public static final int DISTANCES_VIEW = 3;

	//tab type
	public static final int CLASSES_TAB = 0;
	public static final int NOTES_TAB = 1;
	public static final int FRIENDS_TAB = 2;

	public static final String TAB = "TAB";
	public static final String CLASSES_VIEW_TYPE = "CLASSESVIEWTYPE";

	//tab's specs
	public static final String TAB_ONE = "one";
	public static final String TAB_TWO = "two";
	public static final String TAB_THREE = "three";

	//tab titles
	public static final String TAB1_TITLE = "Classes";
	public static final String TAB1_2_TITLE = "Tasks";
	public static final String TAB2_TITLE = "Notes";
	public static final String TAB3_TITLE = "Friends";

	//globals
	private boolean _classesTabIsInThinListView = true;

	TabHost _host;

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		_host = getTabHost();  

		Bundle extras = getIntent().getExtras();
		SelectRightListViewForTasks(extras);		

		if( _classesTabIsInThinListView ) 
		{
			_host.addTab(_host.newTabSpec(TAB_ONE)  
					.setIndicator(TAB1_2_TITLE)  
					.setContent(new Intent(this, TaskListByUpcoming.class)));   
		}             

		_host.addTab(_host.newTabSpec(TAB_TWO)  
				.setIndicator(TAB2_TITLE) 
				.setContent(new Intent(this, NotesList.class))); 


		_host.addTab(_host.newTabSpec(TAB_THREE)  
				.setIndicator(TAB3_TITLE)  
				.setContent(new Intent(this, Friends.class))); 

	}  

	private void SelectRightListViewForTasks(Bundle extras)
	{
		if(extras != null) 
		{
			if(extras.getInt(TAB) == CLASSES_TAB) 
			{
				_classesTabIsInThinListView = false;

				switch(extras.getInt(CLASSES_VIEW_TYPE)) 
				{
				case CLASSES_FATLIST:
					_host.addTab(_host.newTabSpec(TAB_ONE)  
							.setIndicator(TAB1_TITLE)  
							.setContent(new Intent(this, TaskListByCourses.class)));
					break;
				case CLASSES_THINLIST:
					_classesTabIsInThinListView = true;
					break;
				}		
			}
		}
	}
} 

